In electronic circuits, a comparator is a device that can be used to compare two voltages or currents and to provide an output indicative of the relative values of the input signals. Comparators are used in a wide range of electronic devices including, for example, microcontrollers, laptop computers, mobile telephones and other hand-held electronic devices, metering systems, RC timers, and alarm and monitoring circuits, as well other devices.
Rail-to-rail comparators allow the use of almost any input voltage within the power supply range. In such comparators, the signal peak-to-peak amplitude can be as much as (or almost as much as) the full range of the power supply. The differential input voltage (i.e., the voltage difference between two input voltages) thus is limited only by the full swing of the power supply.
A comparator normally changes its output state when the voltage between its inputs passes through approximately zero volts. Small voltage fluctuations resulting, for example, from noise, can cause undesirable rapid changes between the two output states when the input voltage difference is close to zero volts. To prevent this output oscillation, hysteresis can be integrated into the comparator.